﻿using System;
using Softserve.Pottery.Infrastructure;
using Softserve.Pottery.Store.Domains;

namespace Pottery.Frontend.ViewModels
{
    public class ProductDetailsViewModel : IAssignable
    {
        #region IAssignable implemintation

        public void AssignTo(object obj)
        {
            if (obj == null)
                throw new ArgumentNullException();

            if (obj is ProductDetailsViewModel)
            {
                ProductDetailsViewModel model = obj as ProductDetailsViewModel;
                model.Product = Product;
            }

            throw new NotSupportedException();
        }

        #endregion

        #region Public logic

        public static ProductDetailsViewModel FromDomainModel(Product product)
        {
            if (product == null)
                return null;

            return new ProductDetailsViewModel
            {
                Product = product
            };
        }

        #endregion

        #region Properties

        public Product Product { get; set; }

        #endregion
    }
}